home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 11
/
Cream of the Crop 11-1.iso
/
utility
/
horst_2.zip
/
LISTMOD.XAM
< prev
next >
Wrap
Text File
|
1995-12-18
|
4KB
|
149 lines
LISTMOD works well with other batch utilities. Here are some examples to
help people new to redirection, pipes, and batch files.
---------------------------------------------------------------------------
EXAMPLE (1)
I want to back up all configuration files onto a floppy disk, but without
overwriting any that are on the floppy already. PC Magazine's WHEREIS can
find them and LISTMOD does the rest;
whereis *.cfg | listmod if not exist a:$1 copy $1 a: $) nul > bak_cfg.bat
gives a bak_cfg.bat like
if not exist a:\STD_DOS.CFG copy \STD_DOS.CFG a: > nul
if not exist a:\STSCFG.CFG copy \STSCFG.CFG a: > nul
if not exist a:\BWAVE\BWAVE200.CFG copy \BWAVE\BWAVE200.CFG a: > nul
:::
1) a:$1 not a:\$1, because WHEREIS puts in the leading backslash itself.
2) $) hides the redirection character >, to make "> nul" so the batch
file runs quietly. It would otherwise be read by DOS as a redirection
while LISTMOD was working and get confused by anything else on the line
after it.
---------------------------------------------------------------------------
EXAMPLE (2)
Norton 4.5 does not move hidden files when defragmenting the hard disk. I
want to unhide them with ATTRIB -H, defragment, then hide them again.
Keith Graham's well-known file finder FF.COM can find hidden files easily,
but finds system files as well, e.g.,
FF *.* /S gives
C:\IBMBIO.COM
C:\IBMDOS.COM
C:\IMAGE.IDX
C:\TBAVINFO.KEY
C:\DOS\ARC\ARCPARK\DESCRIPT.ION
:::
*BIG* oops... found IBMBIO.COM and IBMDOS.COM as well, and if we move
_those_, the disk won't boot! Enter the Free Software Foundation's Stream
EDitor, SED;
FF *.* /S | SED -F FFJUNK.SED | LISTMOD ATTRIB %%1 $1 > CHANGE.BAT
remember the _two_ % signs because we're at a command line, and where the
SED script FFJUNK.SED is
/fast file finder/d
/Keith P. Graham/d
/Total elapsed time:/d
/For the latest release/d
/call PC Rockland/d
/IBMBIO.COM/d
/IBMDOS.COM/d
The command now gives a CHANGE.BAT like
attrib %1 C:\IMAGE.IDX
attrib %1 C:\TBAVINFO.KEY
attrib %1 C:\DOS\ARC\ARCPARK\DESCRIPT.ION
:::
this can now be called by CHANGE -H to remove the hidden attributes of the
non-dangerous files; and called again with CHANGE +H to put them back again
after defragmenting the disk.
---------------------------------------------------------------------------
EXAMPLE (3)
You have a load of files belonging to one project series, and decide to
give them sequential names, oldest file with lowest number.
DIR /O:D /B *.TXT | LISTMOD REN $1 $#.TXT $) NUL > NUMBER.BAT
The switches after DIR; /O:D, sort by date, oldest first; /B, give a "bare
bones" listing without parent and subdirectories or summaries.
This generates a NUMBER.BAT like;
ren clockon.txt 001.txt > nul
ren enter.txt 002.txt > nul
ren bt_codes.txt 003.txt > nul
:::
To start with, DIR /O:D gives;
Volume in drive C is MS-DOS_5 Serial number is 1A98:B039
Directory of c:\junk\test\*.*
clockon.txt 2279 27/11/90 8:41
enter.txt 2 4/04/93 3:21
bt_codes.txt 8953 8/11/93 13:39
dbugetc.txt 16111 2/03/94 22:52
xeq160.txt 23820 12/03/94 22:08
clearbuf.txt 3991 13/03/94 22:08
. <DIR> 2/04/94 21:25
.. <DIR> 2/04/94 21:25
modem.txt 22459 15/05/94 20:47
stepper.txt 4481 18/05/94 0:00
:::
DIR /O:D /B gives;
clockon.txt
enter.txt
bt_codes.txt
dbugetc.txt
xeq160.txt
clearbuf.txt
modem.txt
stepper.txt
After running the LISTMOD command line to make NUMBER.BAT, then running
NUMBER.BAT itself, and doing DIR /O:D again, gives;
Volume in drive C is MS-DOS_5 Serial number is 1A98:B039
Directory of c:\junk\test\*.*
001.txt 2279 27/11/90 8:41
002.txt 2 4/04/93 3:21
003.txt 8953 8/11/93 13:39
004.txt 16111 2/03/94 22:52
005.txt 23820 12/03/94 22:08
006.txt 3991 13/03/94 22:08
. <DIR> 2/04/94 21:25
.. <DIR> 2/04/94 21:25
007.txt 22459 15/05/94 20:47
008.txt 4481 18/05/94 0:00
Renaming the files as intended.
---------------------------------------------------------------------------
*** these examples by Robert Bull, 30.09.194
<EOF>